import React from 'react';
import PropTypes from 'prop-types';
import { DragSource } from 'react-dnd';
import {ProcessNodeWidget} from "./nodes/process/ProcessNodeWidget";

const nodeSource = {
  beginDrag(props,monitor, component) {
    return props;
  }
};

@DragSource('node-source', nodeSource, (connect, monitor) => ({
  connectDragSource: connect.dragSource(),
  connectDragPreview: connect.dragPreview(),
  isDragging: monitor.isDragging()
}))
export class DragWrapper extends React.Component {
  static propTypes = {
    connectDragSource: PropTypes.func.isRequired,
    isDragging: PropTypes.bool.isRequired,
    children: PropTypes.node
  };

  render() {
    const { isDragging, connectDragSource,connectDragPreview, children } = this.props;

    return connectDragSource(
      <div style={{ opacity: isDragging ? 0.4 : 1 }}>
        {children}
      </div>
    );
    // return  connectDragSource(
    //   <div style={{ opacity: isDragging ? 0.4 : 1 }}>
    //     {children}
    //   </div>
    // );;
  }
}
